package Eyjafjalla.power;

import Eyjafjalla.action.ChooseHandToCloudAction;
import Eyjafjalla.action.TranceAction;
import Eyjafjalla.patch.CloudPatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageRandomEnemyAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class BetweenUsPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:BetweenUsPower";
    private static final PowerStrings powerStrings;

    public BetweenUsPower(AbstractCreature owner, int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.updateDescription();
        String path128 = "EyjafjallaResources/img/power/BetweenUsPower_84.png";
        String path48 = "EyjafjallaResources/img/power/BetweenUsPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.type = PowerType.BUFF;
    }

    @Override
    public void onUseCard(AbstractCard card, UseCardAction action) {
        this.flashWithoutSound();
        boolean cloud = CloudPatch.CloudField.inCloud.get(card);
        if(cloud){
            addToBot(new GainBlockAction(this.owner,this.amount,true));
        }
        else {
            addToBot(new DamageRandomEnemyAction(new DamageInfo(this.owner,this.amount, DamageInfo.DamageType.THORNS), AbstractGameAction.AttackEffect.SLASH_HORIZONTAL));
        }
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0] + this.amount + powerStrings.DESCRIPTIONS[1] + this.amount + powerStrings.DESCRIPTIONS[2];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}




